<?php

namespace App\Http\Controllers\TempFile;

use App\Http\Controllers\Controller;
use App\Models\TempFile\TempFile;
use Illuminate\Http\Request;

class TempFileController extends Controller
{
    public function store(Request $request) {
        $file = $request->file('file');
        logger($file);
        $path = TempFile::upload($file, 'temp-file', 'temp');
        $tempFile = TempFile::create([
            'path' => $path,
        ]);
        return response()->json($tempFile);
    }

    public function delete(TempFile $temp_file) {
        TempFile::deleteFile($temp_file->path);
        return response()->json($temp_file->delete());
    }
}
